package com.sandu.mirrorapp.fragent

import android.os.Bundle
import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.viewpager2.widget.ViewPager2
import com.sandu.lib_mvvm.ext.nav
import com.sandu.lib_mvvm.ext.navigateAction
import com.sandu.mirrorapp.databinding.FragmentSecondBinding
import com.sandu.mirrorapp.R


/**
 * 作者　: sandu
 * 时间　: 2024/11/20
 * 描述　: 测试页面
 */
class SecondFragment(mainViewpager: ViewPager2) : Fragment() {

    private var _binding: FragmentSecondBinding? = null
    private var mainViewpager: ViewPager2 = mainViewpager

    // This property is only valid between onCreateView and
    // onDestroyView.
    private val binding get() = _binding!!

    override fun onCreateView(
        inflater: LayoutInflater, container: ViewGroup?,
        savedInstanceState: Bundle?
    ): View {

        _binding = FragmentSecondBinding.inflate(inflater, container, false)
        return binding.root

    }

    override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
        super.onViewCreated(view, savedInstanceState)

        binding.buttonSecond.setOnClickListener {
//            nav().navigateAction(R.id.action_SecondFragment_to_FirstFragment)
//            findNavController().navigate(R.id.action_SecondFragment_to_FirstFragment)
            mainViewpager.currentItem = 0
        }
    }

    override fun onDestroyView() {
        super.onDestroyView()
        _binding = null
    }
}